// components/navi/navi.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type:String,
      value:'',
      observer:function(){

      }
    },
    first: {
      type:Boolean,
      value:false,
      observer:function(){

      }
    },
    latest: {
      type:Boolean,
      value:false,
      observer:function(){
        
      }
    },
    preid:{
      type:Number,
      value:-1,
      observer:function(newVal,oldVal,changedpath){
        this.setData({
          _preid:newVal
        })
      }
    },
    nextid:{
      type:Number,
      value:-1,
      observer:function (newVal, oldVal, changedpath){
        this.setData({
          _nextid: newVal
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    disLeftSrc: 'images/triangle.dis@left.png',
    leftSrc: 'images/triangle@left.png',
    disrightSrc: 'images/triangle.dis@right.png',
    rightSrc: 'images/triangle@right.png',
    _preid:0,
    _nextid:0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onLeft:function(event){
      if(this.data._nextid > 0){
        this.triggerEvent('left', {}, {})
      }else{
        wx.showToast({
          title: '已经是第一单了！',
        })
      }
      
    },

    onRight:function(event){
      if(this.data._preid >0){
        this.triggerEvent('right', {}, {})
      }else{
        wx.showToast({
          title: '已经是最后单了！',
        })
      }
      
    }

  },

  attached: function () {
    // console.log("navi 组件的 attached")
    // console.log(this.properties)
    // if(this.properties.preid <= 0){
    //   this.properties.first = true
    // }
    // if(this.properties.nextid <= 0) this.properties.latest = true
  }
})
